<extend name="public@base5"/>
<block name="main">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="{:url('Menu/index')}">{:lang('ADMIN_MENU_INDEX')}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{:url('Menu/add')}">{:lang('ADMIN_MENU_ADD')}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{:url('Menu/lists')}">{:lang('ADMIN_MENU_LISTS')}</a>
            </li>
        </ul>
        <form class="js-ajax-form" action="admin/menus/list/order" method="post">
            <div class="table-actions">
                <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                        title="{:lang('Sort')}" data-toggle="tooltip">
                    <i class="fa fa-sort-numeric-asc fa-fw"></i>
                </button>
            </div>
            <table class="table table-hover table-bordered table-list" id="menus-table">
                <thead>
                <tr>
                    <th width="80">{:lang('SORT')}</th>
                    <th width="50">ID</th>
                    <th>{:lang('NAME')}</th>
                    <th>{:lang('APP_CONTROLLER_ACTION')}</th>
                    <th width="80">{:lang('STATUS')}</th>
                    <th width="120">{:lang('ACTIONS')}</th>
                </tr>
                </thead>
                <tbody>
                <tree name="menus" item="menu">
                    <tr id="node-{$menu.id}" class="{$menu.parent_id?'child-of-node-'.$menu.parent_id:''}"
                        style="{$menu.parent_id?'display:none;':''}">
                        <td style="padding-left:20px;">
                            <input name="list_orders[{$menu.id}]" type="text" size="3" value="{$menu.list_order}"
                                   class="input input-order">
                        </td>
                        <td>{$menu.id}</td>
                        <td>{$menu._spacer}{$menu.name}</td>
                        <td>{$menu.app}/{$menu.controller}/{$menu.action}</td>
                        <td>
                            <empty name="menu.status">
                                <span class="badge text-bg-warning">{:lang('HIDDEN')}</span>
                                <else/>
                                <span class="badge text-bg-success">{:lang('DISPLAY')}</span>
                            </empty>
                        </td>
                        <td>
                            <a class="btn btn-xs btn-primary"
                               href="{:url('Menu/add', ['parent_id' =>$menu.id])}"
                               title="{:lang('ADD_SUB_MENU')}"
                               data-toggle="tooltip">
                                <i class="fa fa-plus fa-fw"></i>
                            </a>
                            <a class="btn btn-xs btn-success"
                               href="{:url('Menu/edit', ['id' =>$menu.id])}"
                               title="{:lang('EDIT')}" data-toggle="tooltip">
                                <i class="fa fa-edit fa-fw"></i>
                            </a>
                            <a class="btn btn-xs btn-danger js-ajax-delete"
                               href="javascript:void(0);"
                               data-href="admin/menus/{$menu.id}"
                               title="{:lang('DELETE')}" data-toggle="tooltip">
                                <i class="fa fa-trash fa-fw"></i>
                            </a>
                        </td>
                    </tr>
                </tree>
                </tbody>
                <tfoot>
                <tr>
                    <th width="80">{:lang('SORT')}</th>
                    <th width="50">ID</th>
                    <th>{:lang('NAME')}</th>
                    <th>{:lang('APP_CONTROLLER_ACTION')}</th>
                    <th width="80">{:lang('STATUS')}</th>
                    <th width="120">{:lang('ACTIONS')}</th>
                </tr>
                </tfoot>
            </table>
            <div class="table-actions">
                <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                        title="{:lang('Sort')}" data-toggle="tooltip">
                    <i class="fa fa-sort-numeric-asc fa-fw"></i>
                </button>
            </div>
        </form>
    </div>
</block>
<block name="scripts">
    <script>
        $(document).ready(function () {
            Wind.css('treeTable');
            Wind.use('treeTable', function () {
                $("#menus-table").treeTable({
                    indent: 20
                });
            });
        });
    </script>
</block>
